function merge(left, right) {
  var result = []
  while (left.length > 0 && right.length > 0) {
    if (Number(left[0].aroundPrice) < Number(right[0].aroundPrice)) {
      result.push(left.shift())
    } else {
      result.push(right.shift())
    }
  }
/* 当左右数组长度不等.将比较完后剩下的数组项链接起来即可 */
  return result.concat(left).concat(right)
}
function mergeSort(arr) {
  if (arr.length === 1) { return arr }
  let mid = Math.floor(arr.length / 2)
  let leftArr = arr.slice(0, mid)
  let rightArr = arr.slice(mid)
  return merge(mergeSort(leftArr), mergeSort(rightArr))
}

module.exports = {
  mergeSort
}
